<?php

namespace GPlus\mainBundle\Controller;

use GPlus\mainBundle\Entity\Tag;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;


class DefaultController extends Controller
{
    
    public function indexAction($name)
    {
    	$em = $this->container->get('doctrine')->getEntityManager();

    	$tag = $this->getDoctrine()
    	->getRepository('GPlusmainBundle:Tag')
    	->findOneByTag($name);
    	
    	if(!$tag){
    		
    		$tag = new Tag();
    		$tag->setTag($name);
    		$em->persist($tag);
    		$em->flush();
    	}
        return $this->render('GPlusmainBundle:Default:index.html.twig', array('name' => $name));
    }
    
    
    
}
